<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var i = 1;
        var a = 0;
        var b = 0;
        var add = 0;
        var reduce = 0;

        while (i <= 100) {
            if (i % 2 == 0) {
                a = 1/i;
                add -=a;
                // console.log(add);
                // console.log(a);
            }
            else {
                b = 1/i;
                reduce += b;
                // console.log(b);
                // console.log(reduce);
            }
            i++;
        }
        var res = add + reduce ;
        console.log(res);
    </script>
</body>

</html>